# Maintainer: Renato Silva <br.renatosilva@gmail.com>

pkgname='colordiff'
pkgver='1.0.18'
pkgrel=1
pkgdesc='Diff wrapper with pretty syntax highlighting'
url='https://www.colordiff.org/'
license=('GPL2')
arch=(any)

depends=(diffutils perl)
makedepends=(w3m)
backup=(etc/colordiffrc)
source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/daveewart/colordiff/archive/v${pkgver}.tar.gz"
        001-colorize-filenames.patch
        002-build-fix.patch)
sha256sums=('b78686a64e90032aec7fbfa7477eba2365b9e4ff5d396a1b22744ac2b976eaad'
            'deb380507f19aaa2eb73d7cbff208572f4799b4e94de0cecbba2e3f5f19e2308'
            '24f406f30a5fe3d67b8bbb8ffbb5fd482b44a8774c87197a5181cf16ee1db01b')

prepare() {
    cd "${pkgname}-${pkgver}"
    patch -p1 -i "${srcdir}/001-colorize-filenames.patch"
    patch -p1 -i "${srcdir}/002-build-fix.patch"

    # xmlto txt conversion apparently does not work even with w3m
    # anyhow only man page is packaged
    sed -i "s/xmlto -vv txt colordiff.xml//" makefile
    sed -i "s/mv colordiff.txt README//" makefile
}

package() {
    cd "${pkgname}-${pkgver}"
    make DESTDIR="${pkgdir}" MAN_DIR='/usr/share/man/man1' INSTALL_DIR='/usr/bin' install doc
    install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}
